#include "obj-vect.hh"

#include <iostream>

const int ObjVect::maxsize = 9999;

ObjVect::ObjVect ():
  size_ (0),
  v_ ()
{
  std::cout << "size_ = " << size_ << std::endl;
}

void
ObjVect::add (Object* o)
{
  std::cout << "inserting at size = " << size_ << std::endl;
  v_.insert (std::make_pair (size_, o));
  o->posid (size_);
  size_++;
}

Object*
ObjVect::operator[] (int id)
{
  tbb::concurrent_hash_map<int, Object*>::accessor acc;

  if (!v_.find (acc, id))
  {
    std::cout << "ERROR object "
	      << id
	      << " not found in ObjVect" << std::endl;
    assert (false);
  }

  return acc->second;
}

void
ObjVect::del (Object* o)
{
  assert (o);

  v_.erase (o->posid ());
}

ObjVect::iterator
ObjVect::begin ()
{
  return v_.begin ();
}

ObjVect::iterator
ObjVect::end ()
{
  return v_.end ();
}
